//
//  HomepageCollectionViewCell.m
//  JiuJiuShangCheng
//
//  Created by jiujiukeji on 2018/7/4.
//  Copyright © 2018年 jiujiukeji. All rights reserved.
//

#import "HomepageCollectionViewCell.h"

@implementation HomepageCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUpUI];
    }
    return self;
}
- (void)setUpUI
{
    WeakSelf
    self.goodsImg = [[UIImageView alloc] init];
    _goodsImg.contentMode = UIViewContentModeScaleAspectFill;
    _goodsImg.image = UIImageNamed(@"xixi");
    _goodsImg.layer.masksToBounds = YES;
    _goodsImg.layer.borderWidth = rateWidth(1);
    _goodsImg.layer.borderColor = UIColorWithRGB(236, 235, 235).CGColor;
    [self addSubview:_goodsImg];
    [_goodsImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self);
        make.centerX.equalTo(self);
        make.size.mas_offset(CGSizeMake((kScreenWidth-rateWidth(60)-rateWidth(30))/2, (kScreenWidth-rateWidth(60)-rateWidth(30))/2));
    }];
    
    self.goodsTitle = [UILabel labelWithText:@"商品标题" textColor:UIColorFromRGB(0x333333) fontSize:11];
    [_goodsTitle sizeToFit];
    [self addSubview:_goodsTitle];
    [_goodsTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.goodsImg);
        make.top.equalTo(weakSelf.goodsImg.mas_bottom).offset(rateWidth(10));
        make.width.mas_lessThanOrEqualTo(rateWidth(320));
    }];
    
    self.priceLB = [UILabel labelWithText:@"￥9.90" textColor:UIColorFromRGB(0xff0000) fontSize:15];
    [_priceLB sizeToFit];
    [self addSubview:_priceLB];
    [_priceLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.goodsTitle);
        make.top.equalTo(weakSelf.goodsTitle.mas_bottom).offset(rateWidth(15));
    }];
    
    self.collectionImg = [[UIImageView alloc] init];
    _collectionImg.image = UIImageNamed(@"liuyan");
    [_collectionImg sizeToFit];
    [self addSubview:_collectionImg];
    [_collectionImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.goodsImg);
        make.centerY.equalTo(weakSelf.priceLB);
    }];
    
    self.collectionNumLB = [UILabel labelWithText:@"" textColor:UIColorFromRGB(0x999999) fontSize:11];
    [_collectionNumLB sizeToFit];
    [self addSubview:_collectionNumLB];
    [_collectionNumLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.collectionImg.mas_left).offset(-rateWidth(5));
        make.centerY.equalTo(weakSelf.collectionImg);
    }];
    
}

@end
